package com.learn.springboot.scheduled;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 使用异步任务
 * >编写异步任务类
 * @author wangxing
 * @version 2020/8/3 11:59 Administrator
 */
@Component
public class AsyncTack {
    private Logger logger = LoggerFactory.getLogger(AsyncTack.class);
    @Async//只配置了一个 asyncExecutor1 不指定也会默认使用
    public void asyncTack(){
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info("========={}============{}", "异步任务结束asyncTack",System.currentTimeMillis());
    }
    @Async(value = "asyncExecutor1")
    public void asyncTack01(){
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info("========={}============{}", "异步任务结束asyncTack01",System.currentTimeMillis());
    }

}
